home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 August / macformat-027.iso / mac / Shareware City / Developers / MDP-80 Folder / Documentation / Simulator Manual.text < prev   
Encoding:
Text File  |  1994-09-12  |  28.9 KB  |  716 lines  |  [TEXT/ALFA]

  1.  
  2.                            The MDP-80 Simulator Manual
  3.  
  4.  
  5.                                       by
  6.  
  7.                                Ronald T. Kneusel
  8.  
  9.                                      1994
  10.  
  11.  
  12.  
  13. The MDP-80 simulator was designed to ease the task of learning low level 
  14. machine operations and as an introduction to programming microprocessors.  
  15. This manual describes the operation of the simulator only and 
  16. is not a tutorial.  Basic knowledge of machine code programming is assumed.
  17.  
  18. This manual, the MDP-80 simulator, the MDP-8008 assembler and manual, tutorials,
  19. and sample programs are copyright, 1994, by Ronald T. Kneusel.  Unauthorized 
  20. reproduction or modification in any form is prohibited without prior written 
  21. consent.
  22.  
  23. THE AUTHOR ASSUMES NO RESPONSIBILITY FOR ANY DAMAGE SUSTAINED FROM THE 
  24. USE OF THIS PROGRAM AND MANUAL.  NO WARRANTY IS GIVEN, EITHER EXPLICITLY 
  25. OR IMPLICITLY.  CAVEAT EMPTOR.
  26.  
  27.  
  28. • Chapter 1  -  Introduction
  29.  
  30.  
  31. •• What Is It?
  32.  
  33. The MDP-80 simulator is a Macintosh application that simulates the 
  34. operation of a small microcomputer based on the MDP-8008 microprocessor 
  35. (which is itself a simulation as it is not a `real' microprocessor).  
  36. This simulated computer has a total of 14k (14,336 bytes) of memory with 
  37. the top 2k (from addresses F800 through FFFF) reserved for the system 
  38. monitor ROM.  
  39. The remaining 12k is RAM memory (addresses 0000 through 
  40. 2FFF).  Reading and writing to addresses in the range 3000 through F7FF 
  41. will not cause an error but is the functional equivalent of reading and 
  42. writing to empty sockets on the motherboard of an actual computer. The 
  43. MDP-80 is connected to a simple terminal and keyboard.  
  44. Input/Output is accomplished by checking specific memory locations.  The 
  45. microprocessor does not support interrupts and there is no form of disk 
  46. I/O.  The simulator provides a means for loading a program to memory from 
  47. a file on the Macintosh, but programs written in the simulator cannot be 
  48. saved to disk.
  49.  
  50. ••• The MDP-8008 Microprocessor
  51.  
  52. A summary of the MDP-8008 microprocessor instruction set is given in 
  53. Opcodes table.  The MDP-8008 is an 8-bit microprocessor with one 
  54. accumulator and two general purpose 8-bit registers, X and Y.  The 
  55. microprocessor uses page 2 (0100 through 01FF) as a system stack with the 
  56. current value of the stack register accessible via the X register.  In 
  57. addition, the MDP-8008 has a special purpose `processor status register' 
  58. (P) which contains flags that indicate the current state of the microprocessor.
  59. These flags are tested by the branch instructions.  The flags are 
  60. negative (N), carry (C), zero (Z), less than (L), and greater than (G).  
  61.  
  62.  
  63. ••• The System Monitor
  64.  
  65. The system monitor is itself an MDP-8008 program that will allow the user 
  66. to examine and change memory and to run programs.  It is run automatically 
  67. at startup, displaying a message identifying the version. It then prints 
  68. an `*' and waits for a line of input.  The monitor is fully described
  69. in the first part of Chapter 2.  The monitor also provides a 
  70. collection of highly useful subroutines that will greatly ease the task 
  71. of writing programs.  These include input (numbers, lines of text) and 
  72. output (characters, strings, and numbers) subroutines.
  73.  
  74.  
  75. •• Features
  76.  
  77. The MDP-80 features an `invisible' simulator that only makes its presence 
  78. known when loading programs and memory from disk.  The system monitor is a 
  79. true MDP-8008 program and not an extension of the simulator.  The source code 
  80. for the system monitor is included with the simulator package in the  
  81. _MDP-8008 Assembler User Manual_.  Not being part of the simulator 
  82. program makes the code in the system monitor available to the user, thereby 
  83. making input and output much easier.
  84.  
  85. The assembler should be used for all but the smallest programs.  
  86. On Macintoshes using MultiFinder or System 7.x it is easy to run 
  87. the assembler, the simulator, and a text editor (not included) at the same 
  88. time and thereby create a fast write/assemble/execute loop.
  89.  
  90. The simulator allows for the loading of assembly object files from disk 
  91. along with the loading and saving of memory.  The ability to load and 
  92. save memory makes it possible to work on programs in machine code before 
  93. using the assembler.
  94.  
  95.  
  96. • Chapter 2  -  Quick Start
  97.  
  98. This chapter serves as a quick introduction to the simulator and 
  99. describes the system monitor commands.  A sample program is also presented.
  100.  
  101. •• System Monitor Commands
  102.  
  103. The system monitor understands five single letter commands regardless of 
  104. spacing and case.  A summary of the commands is:
  105.  
  106.  
  107.                         System Monitor Commands       
  108.                       
  109.  Command                     Function                         Example Use
  110.  -----------   --------------------------------------------  --------------
  111.  X `address'   eXamine memory, dump 10 lines in hexadecimal     X 400 
  112.  L `address'   List memory, disassemble 10 lines                L 400
  113.  S `address'   Substitute memory, enter new value, `!' to end   S 400
  114.  G `address'   Go (run program)                                 G 400
  115.  `address'     display contents of the address entered          12EF
  116.  !             clear the screen and home the cursor             !
  117.  
  118.  
  119.  
  120. ••• Examine Command
  121.  
  122. The `X' (eXamine) command, followed by an address of one to four digits, 
  123. will produce a ten line hexadecimal dump of memory beginning at the 
  124. address entered.  For example,
  125.  
  126. *X 400  (entered by the user)
  127. 0400-A9 41 20 F8 76 60 00 00
  128. 0408-00 00 00 00 00 00 00 00
  129. 0410-00 00 00 00 00 00 00 00
  130. 0418-00 00 00 00 00 00 00 00
  131. 0420-00 00 00 00 00 00 00 00
  132. 0428-00 00 00 00 00 00 00 00
  133. 0430-00 00 00 00 00 00 00 00
  134. 0438-00 00 00 00 00 00 00 00
  135. *
  136.  
  137.  
  138. ••• List Command
  139.  
  140. For a disassembled listing of memory use the `L' (List) command.  For 
  141. example,
  142.  
  143. *L 400   (again entered by the user)
  144. 0400- A9 41    LDA #41
  145. 0402- 20 F8 76 JSR $F876
  146. 0405- 60       RTS
  147. 0408- 00       BRK
  148. 0409- 00       BRK
  149. 040A- 00       BRK
  150. 040B- 00       BRK
  151. 040C- 00       BRK
  152. 040D- 00       BRK
  153. 040E- 00       BRK
  154. 040F- 00       BRK
  155. 0410- 00       BRK
  156. 0411- 00       BRK
  157. 0412- 00       BRK
  158. 0413- 00       BRK
  159. 0414- 00       BRK
  160. *
  161.  
  162.  
  163. ••• Substitute Command
  164.  
  165. To change the contents of memory use the `S' (Substitute) command 
  166. followed by an address.  To change the value of a memory location enter 
  167. the new value, to leave it unchanged press `return'.  To exit substitute 
  168. mode enter `!'.  For example,
  169.  
  170. *S 400   (user input)
  171. 0400-00  A9    (entered by the user)
  172. 0401-00  41
  173. 0402-00  20
  174. 0403-00  F8
  175. 0404-00  76
  176. 0405-00  60
  177. 0406-00  !     (end input)
  178. *
  179.  
  180.  
  181. ••• Go Command
  182.  
  183. Run a machine language program by entering `G' followed by the first 
  184. address in the program.  Be sure to end all programs with a 60 (RTS) 
  185. instruction to return to the monitor.  For example, using the code 
  186. entered above, 
  187.  
  188. *G 400        (user input)
  189. A*            (program outputs `A' then back to monitor)
  190.  
  191.  
  192. ••• Other Commands
  193.  
  194. Typing `!' will clear the screen and home the cursor.  Typing a valid 
  195. hexadecimal address (one to four digits) will display the current 
  196. contents of that address.
  197.  
  198.  
  199. •• Example - the Alphabet
  200.  
  201. As an illustration of the simulator we now present a small example 
  202. program to print the letters of the alphabet.  This program uses the 
  203. _COUT monitor subroutine at location F876 to print the character 
  204. in the accumulator.  Try this example for yourself by entering the values 
  205. listed,
  206.  
  207. MDP-80 Monitor ROM version 1.0
  208.  
  209. *S 400
  210. 0400-00  A9
  211. 0401-00  41
  212. 0402-00  20
  213. 0403-00  F8
  214. 0404-00  76
  215. 0405-00  AE
  216. 0406-00  88
  217. 0407-00  5B
  218. 0408-00  D1
  219. 0409-00  04
  220. 040A-00  02
  221. 040B-00  A9
  222. 040C-00  0D
  223. 040D-00  20
  224. 040F-00  F8
  225. 0410-00  76
  226. 0411-00  60
  227. 0412-00  !
  228. *G 400
  229. ABCDEFGHIJKLMNOPQRSTUVWXYZ
  230. *
  231.  
  232. As an exercise, change the program to output the alphabet in lowercase 
  233. (ASCII values 61 through 7A) by changing 401 to 61 and 407 to 7B.
  234.  
  235.  
  236. • Chapter 3  -  The Simulator Application
  237.  
  238. The simulator application uses two menus, File and Edit.  The Edit menu is 
  239. for desk accessories and is not used.
  240.  
  241. •• The File Menu
  242.  
  243. The "File" menu options are "Load file", "Load memory", "Save memory", and 
  244. "Quit".  The last one is self-evident.  The Load file option loads assembly 
  245. language object files into the simulator's memory.  It brings up a standard 
  246. Macintosh dialog box for the user to enter the name of an assembler 
  247. object file (.OBJ) to load.  The simulator displays the beginning 
  248. address of the file and returns to the system monitor.
  249.  
  250. The "Load memory" and "Save memory" options read or write the 
  251. entire contents of the simulator's memory to a disk file.  This is useful 
  252. when writing programs without using the assembler.  To use this feature 
  253. make a copy of the supplied file _MDP-80 memory_ in the Finder and 
  254. name it what you will.  Then, when in the simulator and ready to save the 
  255. memory, select "Save memory" and use the dialog box to select the 
  256. file just created.  The entire contents of the simulator's memory will be 
  257. written to this file.  Use "Load memory" to restore a memory image.  
  258. If a disk error occurs the simulator will indicate the error code and exit.
  259.  
  260. •• Breaking an Infinite Loop
  261.  
  262. The mouse button resets the simulator.  Pressing it will 
  263. interrupt the program currently running and return to the monitor.  
  264. Embedding a BRK (00) instruction in a program will cause the 
  265. simulator to jump to the address FFFA which contains a jump to the 
  266. break routine. 
  267.  
  268. • Chapter 4  -  MDP-8008 Reference
  269.  
  270. The MDP-8008 microprocessor has 52 instructions and 7 addressing modes.  
  271. The _opcodes_ table gives a summary of the MDP-8008 instruction set. The 
  272. instruction names are given in the _full name_ table. The second column of 
  273. the _opcodes_ table indicates with an `*' which of the processor status 
  274. flags are affected by each instruction.  The flags are (N) negative (bit 
  275. seven is set), (C) carry, (Z) zero, (L) less than, and (G) greater than.
  276.  
  277. •• MDP-8008 addressing modes
  278.  
  279. An instruction's addressing mode determines the way in which the 
  280. instruction will access and use memory.  The seven modes supported by the 
  281. MDP-8008 are implied, immediate, absolute, absolute indexed, zero page, 
  282. relative, and indirect indexed.
  283.  
  284. ••• Implied addressing
  285.  
  286. The implied address in implied addressing is the accumulator.  Implied 
  287. mode is used by single byte instructions that only act on the accumulator 
  288. and do not reference memory.
  289.  
  290. ••• Immediate addressing
  291.  
  292. The value used in immediate mode addressing is the next byte of the 
  293. program, or the first operand.  The target of the instruction is one of 
  294. the microprocessor's registers which is loaded with the immediate value.  
  295. For example, A9 F3 will load the accumulator with the value F3.  
  296.  
  297. ••• Absolute addressing
  298.  
  299. An 8-bit microprocessor like the MDP-8008 can access a total of 65536 
  300. memory locations.  It therefore takes two bytes to represent the address 
  301. of any memory location.  Absolute addressing uses two operand bytes 
  302. (the first two bytes of the program following the byte containing the 
  303. opcode) to represent the address of a memory location.  For example, B9 1E 37 
  304. will store the current value of the accumulator in location 1E37.
  305.  
  306. ••• Absolute indexed addressing
  307.  
  308. Similar to absolute addressing, absolute indexed addressing uses as a 
  309. target address the value obtained when the address represented by the 
  310. operand bytes is added to the current value of the X register.  If the X 
  311. register contains 14 and the instruction is BD 1E 38 the contents of the 
  312. accumulator will be stored in location 1E38 + 14 = 1E4C.  Absolute indexed 
  313. addressing is particularly useful when dealing with lists.
  314.  
  315. ••• Indirect indexed addressing
  316.  
  317. The target address in indirect index addressing is found by taking the 
  318. absolute address in the operands, reading the two byte address that 
  319. starts at the given address and adding the contents of the X register to 
  320. get the final address.  For example, suppose the instruction being 
  321. executed (in assembly form) is 61 2E 33.  If the values stored 
  322. in memory locations 2E33 and 2E34 are 14 and 1C and the current value 
  323. of the X register is A4 then the accumulator will be loaded with the 
  324. contents of location 141C + A4 = 14C0.
  325.  
  326. ••• Zero page addressing
  327.  
  328. Zero page addressing takes advantage of the fact that the first 256 
  329. memory locations can be addressed in a single byte (00 to FF).
  330. Therefore, all instructions using the zero page are only two bytes long, 
  331. which can add up to a significant savings if frequently used locations 
  332. are in the zero page.
  333.  
  334. ••• Relative addressing
  335.  
  336. Only the branch instructions use relative addressing.  Instead of 
  337. specifying an absolute location in memory, a relative address is a 
  338. positive or negative offset from the current address.  The use of 
  339. relative addressing allows one to write code that will run at any 
  340. location in memory.  Relative addressing uses one operand and as a result 
  341. can reference locations that are -128 to +127 bytes from the current 
  342. location.  The Forebranch and Backbranch tables can be used to 
  343. determine the appropriate operand for a specific branch.
  344.  
  345.  
  346.            +-----------------------------------------------+
  347.            |                                               |
  348.            |                  TABLES                       |
  349.            |                                               |
  350.            +-----------------------------------------------+
  351.  
  352.  
  353.  
  354.  
  355.      •• Summary of MDP-8008 instruction set ••
  356.  
  357.  
  358. Label  N-C-ZLG-  Imp  Imm  Abs  AbX  Zer  Rel  Ind 
  359. -----+----------+----+----+----+----+----+----+----+
  360.  ADC | *-*-*--- |    | A5 | B5 | BE |    |    |    |
  361.  AND | ----*--- |    | A0 | 99 |    |    |    |    |
  362.  BCC | -------- |    |    | D5 |    |    | D4 |    |
  363.  BCS | -------- |    |    | DB |    |    | DA |    |
  364.  BEQ | -------- |    |    | D3 |    |    | D2 |    |    
  365.  BGT | -------- |    |    | D9 |    |    | D8 |    |    
  366.  BLT | -------- |    |    | D7 |    |    | D6 |    |    
  367.  BNE | -------- |    |    | D1 |    |    | D0 |    |    
  368.  BNG | -------- |    |    | DD |    |    | DC |    |    
  369.  BPL | -------- |    |    | DF |    |    | DE |    |    
  370.  BRA | -------- |    |    |    |    |    | E0 |    |    
  371.  BRK | -------- | 00 |    |    |    |    |    |    |    
  372.  CLC | --*----- | 54 |    |    |    |    |    |    |    
  373.  CMP | ----***- |    | 88 | 89 | 8A | CB |    |    |    
  374.  CPX | ----***- |    | 86 | 85 |    | CC |    |    |    
  375.  CPY | ----***- |    | 8B | 8C |    | CD |    |    |    
  376.  DCA | ----*--- | AF |    |    |    |    |    |    |    
  377.  DEC | ----*--- |    |    | 45 | 34 |    |    |    |    
  378.  DEX | ----*--- | C7 |    |    |    |    |    |    |    
  379.  DEY | ----*--- | C5 |    |    |    |    |    |    |    
  380.  EOR | ----*--- |    | A2 | 97 |    |    |    |    |    
  381.  INA | ----*--- | AE |    |    |    |    |    |    |    
  382.  INC | ----*--- |    |    | 46 | 35 |    |    |    |    
  383.  INX | ----*--- | E8 |    |    |    |    |    |    |    
  384.  INY | ----*--- | EE |    |    |    |    |    |    |    
  385.  JMP | -------- |    |    | 4C |    |    |    |    |    
  386.  JSR | -------- |    |    | 20 |    |    |    |    |    
  387.  LDA | *---*--- |    | A9 | AA | AD | C0 |    | 61 | 
  388.  LDX | *---*--- |    | A8 | AB |    | C2 |    |    |    
  389.  LDY | *---*--- |    | A6 | AC |    | C4 |    |    |    
  390.  LSH | --*----- | 26 |    |    |    |    |    |    |    
  391.  NOP | -------- | EA |    |    |    |    |    |    |    
  392.  ORA | ----*--- |    | A1 | 98 |    |    |    |    |    
  393.  PHA | -------- | 3C |    |    |    |    |    |    |    
  394.  PHP | -------- | 33 |    |    |    |    |    |    |    
  395.  PLA | -------- | 3D |    |    |    |    |    |    |    
  396.  PLP | -------- | 36 |    |    |    |    |    |    |    
  397.  ROL | --*----- | 28 |    |    |    |    |    |    |    
  398.  ROR | --*----- | 27 |    |    |    |    |    |    |    
  399.  RSH | --*----- | 29 |    |    |    |    |    |    |    
  400.  RTS | -------- | 60 |    |    |    |    |    |    |    
  401.  SBC | *-*-*--- |    | A4 | BB | BA |    |    |    |    
  402.  SEC | --*----- | 55 |    |    |    |    |    |    |    
  403.  STA | -------- |    |    | B9 | BD | C6 |    | 63 | 
  404.  STX | -------- |    |    | B8 |    | C8 |    |    |    
  405.  STY | -------- |    |    | B6 |    | CA |    |    |    
  406.  TAX | -------- | 14 |    |    |    |    |    |    |    
  407.  TAY | -------- | 13 |    |    |    |    |    |    |    
  408.  TSX | -------- | 07 |    |    |    |    |    |    |    
  409.  TXA | -------- | 12 |    |    |    |    |    |    |    
  410.  TXS | -------- | 10 |    |    |    |    |    |    |    
  411.  TYA | -------- | 11 |    |    |    |    |    |    |
  412. -----+----------+----+----+----+----+----+----+----+     
  413.  
  414.  
  415.  
  416.    •• MDP-8008 instruction names ••
  417.  
  418.  
  419.  Mnemonic | Function
  420. ----------+---------------------------------
  421.  ADC      | Add to accumulator with carry               
  422.  AND      | AND accumulator with memory                 
  423.  BCC      | Branch on carry clear                       
  424.  BCS      | Branch on carry set                         
  425.  BEQ      | Branch on equal or zero                     
  426.  BGT      | Branch on greater than                      
  427.  BLT      | Branch on less than                         
  428.  BNE      | Branch on not equal or not zero             
  429.  BNG      | Branch on negative set                      
  430.  BPL      | Branch on positive (not negative)           
  431.  BRA      | Unconditional relative branch               
  432.  BRK      | Break                                       
  433.  CLC      | Clear carry flag                            
  434.  CMP      | Compare accumulator to memory               
  435.  CPX      | Compare X register to memory                
  436.  CPY      | Compare Y register to memory                
  437.  DCA      | Decrement accumulator by one                
  438.  DEC      | Decrement memory by one                     
  439.  DEX      | Decrement X register by one                 
  440.  DEY      | Decrement Y register by one                 
  441.  EOR      | Exlusive-OR accumulator with memory         
  442.  INA      | Increment accumulator by one                
  443.  INC      | Increment memory by one                     
  444.  INX      | Increment X register by one                 
  445.  INY      | Increment Y register by one                 
  446.  JMP      | Jump to address                             
  447.  JSR      | Jump to subroutine at address               
  448.  LDA      | Load the accumulator with memory            
  449.  LDX      | Load the X register with memory             
  450.  LDY      | Load the Y register with memory             
  451.  LSH      | Bit shift accumulator left, no carry        
  452.  NOP      | No operation                                
  453.  ORA      | OR accumulator with memory                  
  454.  PHA      | Push accumulator on stack                   
  455.  PHP      | Push processor status on stack              
  456.  PLA      | Pull accumulator from stack                 
  457.  PLP      | Pull processor status from stack            
  458.  ROL      | Rotate accumulator to the left with carry   
  459.  ROR      | Rotate accumulator to the right with carry  
  460.  RSH      | Bit shift accumulator right, no carry       
  461.  RTS      | Return from subroutine                      
  462.  SBC      | Subtract memory from accumulator with carry 
  463.  SEC      | Set carry flag                              
  464.  STA      | Store accumulator in memory at address      
  465.  STX      | Store X register in memory at address       
  466.  STY      | Store Y register in memory at address       
  467.  TAX      | Transfer accumulator to X register          
  468.  TAY      | Transfer accumulator to Y register          
  469.  TSX      | Transfer stack pointer to X register        
  470.  TXA      | Transfer X register to accumulator          
  471.  TXS      | Transfer X register to stack pointer        
  472.  TYA      | Transfer Y register to accumulator          
  473.  
  474.  
  475.  
  476.                  •• Forward relative branch table ••
  477.  
  478.  
  479. Use:  Find the number of bytes forward by locating the value in the body and 
  480.       reading the most significant and least significant hexadecimal digits 
  481.       from the row and column headings respectively.  Example, to branch 
  482.       forward 73 bytes, locate 73 in the body of the table and choose 4 from 
  483.       the row and 9 from the column to make 49.
  484.  
  485.  
  486.   | 0  | 1  | 2  | 3  | 4  | 5  | 6  | 7  | 8  | 9  | A  | B  | C  | D | E | F
  487. --+----+----+----+----+----+----+----+----+----+----+----+----+----+---+---+---
  488. 0 | 0  | 1  | 2  | 3  | 4  | 5  | 6  | 7  | 8  | 9  |10  |11  |12  |13 |14 |15 
  489. 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |29 |30 |31 
  490. 2 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |45 |46 |47 
  491. 3 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 |61 |62 |63 
  492. 4 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 |77 |78 |79 
  493. 5 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 |93 |94 |95 
  494. 6 | 96 | 97 | 98 | 99 |100 |101 |102 |103 |104 |105 |106 |107 |108 |109|110|111 
  495. 7 |112 |113 |114 |115 |116 |117 |118 |119 |120 |121 |122 |123 |124 |125|126|127 
  496.  
  497.  
  498.  
  499.                  •• Backward relative branch table ••
  500.  
  501. Use: Find the number of bytes backwards by locating the value in the 
  502.      body and reading the most significant and least significant hexadecimal
  503.      digits from the row and column headings respectively.  Example, to 
  504.      branch backwards 73 bytes, locate 73 in the body of the table and choose 
  505.      B from the row and 7 from the column to make B7.
  506.      
  507.   | 0  | 1  | 2  | 3  | 4  | 5  | 6  | 7  | 8  | 9  | A  | B  | C  | D | E | F
  508. --+----+----+----+----+----+----+----+----+----+----+----+----+----+---+---+--- 
  509. 8 | 128| 127| 126| 125| 124| 123| 122| 121| 120| 119| 118| 117| 116|115|114|113 
  510. 9 | 112| 111| 110| 109| 108| 107| 106| 105| 104| 103| 102| 101| 100| 99| 98| 97 
  511. A | 96 | 95 | 94 | 93 | 92 | 91 | 90 | 89 | 88 | 87 | 86 | 85 | 84 | 83| 82| 81 
  512. B | 80 | 79 | 78 | 77 | 76 | 75 | 74 | 73 | 72 | 71 | 70 | 69 | 68 | 67| 66| 65 
  513. C | 64 | 63 | 62 | 61 | 60 | 59 | 58 | 57 | 56 | 55 | 54 | 53 | 52 | 51| 50| 49 
  514. D | 48 | 47 | 46 | 45 | 44 | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35| 34| 33 
  515. E | 32 | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19| 18| 17 
  516. F | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9  | 8  | 7  | 6  | 5  | 4  | 3 | 2 | 1 
  517.  
  518.  
  519.  
  520. •• MDP-80 System Memory Map and ASCII Table
  521.  
  522. The diagram below shows how memory is used by the MDP-80 simulator.  Zero
  523. page is available to the user if locations below 15 are unaffected.  All of 
  524. page one (0100 - 01FF) is reserved for the microprocessor's system stack.  
  525. Several locations in page two (0200 - 02FF) are reserved for keyboard and 
  526. screen I/O as shown in the _special locations_ table.  While it is possible 
  527. to use these locations directly there exist system monitor routines to handle 
  528. keyboard and terminal I/O.  The ASCII table summarizes the 7-bit ASCII code.
  529.  
  530.  
  531.  
  532.                       •• Page 2 special locations ••
  533.  
  534.  
  535.          +----------+------+-----------------------------------------+
  536.          | Location | Name | Purpose                                 |
  537.          +----------+------+-----------------------------------------+
  538.          |  0200    | KOUT | Put character to print here             | 
  539.          |  0201    | CSTB | And set this to non-zero to print       |
  540.          |  0202    | KBDS | Set to non-zero to wait for a keypress  |
  541.          |  0203    | KEYB | Get character typed from here           |
  542.          +----------+------+-----------------------------------------+
  543.  
  544.  
  545.  
  546.                         •• MDP-80 Memory Map ••
  547.  
  548.  
  549. +-----------------------+
  550. |                       |
  551. |     F800 - FFFF       |    System Monitor
  552. |                       |
  553. +-----------------------+
  554. |                       |
  555. |     3000 - F7FF       |    Undefined addresses
  556. |                       |
  557. +-----------------------+
  558. |                       |
  559. |                       |
  560. |                       |
  561. |     0400 - 2FFF       |    RAM available to user
  562. |                       |
  563. |                       |
  564. |                       |
  565. |                       |
  566. +-----------------------+
  567. |     0300 - 03FF       |    Text input buffer
  568. +-----------------------+
  569. |     0200 - 02FF       |    I/O locations ( 0208 - 02FF available )
  570. +-----------------------+
  571. |     0100 - 01FF       |    MDP-8008 stack
  572. +-----------------------+
  573. |     0000 - 00FF       |    Zero Page ( 0016 - 00FF avilable )
  574. +-----------------------+
  575.  
  576.  
  577.  
  578.                       •• 7-bit ASCII codes ••
  579.  
  580.  
  581.    Char     | Hex| Dec| Char | Hex | Dec | Char | Hex | Dec | Char | Hex | Dec
  582. ------------+----+----+------+-----+-----+------+-----+-----+------+-----+-----
  583. ctl-@ (NUL) | 00 | 00 | <sp> | 20  | 32  | @    | 40  | 64  | sp   | 60  | 96 
  584. ctl-A (SOH) | 01 | 01 | !    | 21  | 33  | A    | 41  | 65  | a    | 61  | 97 
  585. ctl-B (STX) | 02 | 02 | "    | 22  | 34  | B    | 42  | 66  | b    | 62  | 98 
  586. ctl-C (ETX) | 03 | 03 | #    | 23  | 35  | C    | 43  | 67  | c    | 63  | 99 
  587. ctl-D (EOT) | 04 | 04 | $    | 24  | 36  | D    | 44  | 68  | d    | 64  |100 
  588. ctl-E (ENQ) | 05 | 05 | %    | 25  | 37  | E    | 45  | 69  | e    | 65  |101 
  589. ctl-F (ACK) | 06 | 06 | |    | 26  | 38  | F    | 46  | 70  | f    | 66  |102 
  590. ctl-G (BEL) | 07 | 07 |  '   | 27  | 39  | G    | 47  | 71  | g    | 67  |103 
  591. ctl-H (BS)  | 08 | 08 |  (   | 28  | 40  | H    | 48  | 72  | h    | 68  |104 
  592. ctl-I (HT)  | 09 | 09 |  )   | 29  | 41  | I    | 49  | 73  | i    | 69  |105 
  593. ctl-J (LF)  | 0A | 10 |  *   | 2A  | 42  | J    | 4A  | 74  | j    | 6A  |106 
  594. ctl-K (VT)  | 0B | 11 |  +   | 2B  | 43  | K    | 4B  | 75  | k    | 6B  |107 
  595. ctl-L (FF)  | 0C | 12 |  ,   | 2C  | 44  | L    | 4C  | 76  | l    | 6C  |108 
  596. ctl-M (CR)  | 0D | 13 |  -   | 2D  | 45  | M    | 4D  | 77  | m    | 6D  |109 
  597. ctl-N (SO)  | 0E | 14 |  .   | 2E  | 46  | N    | 4E  | 78  | n    | 6E  |110 
  598. ctl-O (SI)  | 0F | 15 |  /   | 2F  | 47  | O    | 4F  | 79  | o    | 6F  |111 
  599. ctl-P (DLE) | 10 | 16 |  0   | 30  | 48  | P    | 50  | 80  | p    | 70  |112 
  600. ctl-Q (DC1) | 11 | 17 |  1   | 31  | 49  | Q    | 51  | 81  | q    | 71  |113 
  601. ctl-R (DC2) | 12 | 18 |  2   | 32  | 50  | R    | 52  | 82  | r    | 72  |114 
  602. ctl-S (DC3) | 13 | 19 |  3   | 33  | 51  | S    | 53  | 83  | s    | 73  |115 
  603. ctl-T (DC4) | 14 | 20 |  4   | 34  | 52  | T    | 54  | 84  | t    | 74  |116 
  604. ctl-U (NAK) | 15 | 21 |  5   | 35  | 53  | U    | 55  | 85  | u    | 75  |117 
  605. ctl-V (SYN) | 16 | 22 |  6   | 36  | 54  | V    | 56  | 86  | v    | 76  |118 
  606. ctl-W (ETB) | 17 | 23 |  7   | 37  | 55  | W    | 57  | 87  | w    | 77  |119 
  607. ctl-X (CAN) | 18 | 24 |  8   | 38  | 56  | X    | 58  | 88  | x    | 78  |120 
  608. ctl-Y (EM)  | 19 | 25 |  9   | 39  | 57  | Y    | 59  | 89  | y    | 79  |121 
  609. ctl-Z (SUB) | 1A | 26 |  :   | 3A  | 58  | Z    | 5A  | 90  | z    | 7A  |122 
  610. ctl-[ (ESC) | 1B | 27 |  ;   | 3B  | 59  | [    | 5B  | 91  | {    | 7B  |123 
  611. ctl-\ (FS)  | 1C | 28 |  <   | 3C  | 60  | \    | 5C  | 92  | |    | 7C  |124 
  612. ctl-] (GS)  | 1D | 29 |  =   | 3D  | 61  | ]    | 5D  | 93  | }    | 7D  |125 
  613. ctl-^ (RS)  | 1E | 30 |  >   | 3E  | 62  | ^    | 5E  | 94  | ~    | 7E  |126  
  614. ctl-<- (VS) | 1F | 31 |  ?   | 3F  | 63  |<-    | 5F  | 95  | DEL  | 7F  |127 
  615.  
  616.  
  617.  
  618. • Chapter 5  -  Useful Monitor Subroutines
  619.  
  620. The simulator's built in system monitor program occupies the 2K of memory 
  621. from F800 to FFFF and contains the routines necessary to make it possible 
  622. to enter, execute, and modify machine language programs.  It also 
  623. contains a number of useful routines for printing strings and numbers, 
  624. entering data, and converting strings to numbers.
  625.  
  626.  
  627. ••  _COUT | F876 | Output character in A
  628.  
  629. Description: Displays the character whose ASCII code is stored in the 
  630.              accumulator.
  631. Registers altered: None.
  632.  
  633.  
  634. •• _KEYIN | F87D | Input character from keyboard
  635.  
  636. Description: Waits for a key to be pressed and places the ASCII value in 
  637.              the accumulator.
  638. Registers altered: A.
  639.  
  640.  
  641. •• _INPUT | F87D | Input a line of text, with prompt  
  642.   _INPUT1 | F889 | Input a line of text, no prompt
  643.  
  644. Description: Inputs a line of text. Characters are stored starting 
  645.              at location 0300.  Backspace and delete keys work as normal. 
  646.              X holds the length on exit.
  647. Registers altered: A, X.
  648.  
  649.  
  650. •• _PRINT | F8D2 | Print a null terminated string  
  651.  
  652. Description: Displays the null terminated string the address of which is 
  653.              in A (MSB) and X (LSB).
  654. Registers altered: A, X.
  655.  
  656.  
  657. •• _PRINTHEX | F8E9 | Print A as a hexadecimal number  
  658.  
  659. Description: Display the accumulator as a two digit hexadecimal number.
  660. Registers altered: A.
  661.  
  662.  
  663. •• _PRINTWORD | F920 | Print AX as a four digit hexadecimal number  
  664.  
  665. Description: Displays AX as a four digit number. A holds the high
  666.              part, X holds the low.
  667. Registers altered: A, X.
  668.  
  669.  
  670. •• _UPPER | F928 | Convert a string to uppercase  
  671.  
  672. Description: Converts the null terminated string starting at 
  673.               the address in AX to uppercase.
  674. Registers altered: A, X.
  675.  
  676.  
  677. •• _KILLB | F952 | Remove the blanks from a string  
  678.  
  679. Description: Removes the blanks from the null terminated string that starts 
  680.              at the address in AX.
  681. Registers altered: A, X.
  682.  
  683.  
  684. •• _LENGTH | F989 | Find the length of a string  
  685.  
  686. Description: Returns in X the length of the null terminated string
  687.              pointed to by 06 and 07.
  688. Registers altered: A, X.
  689.  
  690.  
  691. •• _NUMBER | F9DD | Convert a string to a number  
  692.  
  693. Description: Converts the null terminated string in AX into a 16-bit
  694.              hexadecimal number stored in 01 and 02.
  695. Registers altered: A, X, and Y.
  696.  
  697.  
  698. •• _REG | FF7F | Display current register values  
  699.  
  700. Description: Displays the current register values.
  701. Registers altered: None.
  702.  
  703.  
  704. •• _BLANKS | FFD8 | Output blank spaces  
  705.  
  706. Description: Displays blank spaces, count in X.
  707. Registers altered: A, X.
  708.  
  709.  
  710. Author's address:
  711.  
  712.         Ronald T. Kneusel
  713.         8725 West Burdick Avenue
  714.         Milwaukee, WI  53227  USA
  715.         (414) 545-7557
  716.